package com.harlaus.captcha.controller;

import com.harlaus.captcha.entity.SliderCaptcha;
import com.harlaus.captcha.service.CaptchaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/captcha")
public class CaptchaController {

    @Autowired
    private CaptchaService captchaService;

    @GetMapping("pullCaptcha")
    public SliderCaptcha pullCaptcha(){
        return captchaService.getCaptcha();
    }

    @PostMapping("pushImage")
    public Boolean pushImage(@RequestBody List<SliderCaptcha> sliderCaptchas){
        return captchaService.putCaptcha(sliderCaptchas);
    }

    @PostMapping("checkCaptcha")
    public Boolean checkCaptcha(@RequestBody SliderCaptcha sliderCaptcha){
        return captchaService.checkCaptcha(sliderCaptcha);
    }
}
